<template>
    <!-- 申请弹窗 -->
    <a-modal
        destroyOnClose
        :title="title"
        :width="width"
        :visible="visible"
        :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
        @ok="handleOk"
        @cancel="handleCancel"
    >
        <MaterialApplyForm ref="modalForm" :returnTimeEditable="returnTimeEditable" :editable="editable" :editableFiexd="editableFiexd" :dataId="dataId" v-model="formData" @ok="visible=false"></MaterialApplyForm>
    </a-modal>
</template>

<script>

import MaterialApplyForm from './MaterialApplyForm'
export default {
    name:'MaterialApplyModal',
    components:{
        MaterialApplyForm
    },
    data(){
        return {
            title:'',
            width:800,
            visible: false,
            disableSubmit: false,
            returnTimeEditable:false,
            editable:true,
            editableFiexd:{},
            formData:{},
            workflowModel:{
                operation: "start"
            },
            dataId:'',
            successTxt:''
        }
    },
    methods:{
        add () {
            this.edit({
                actStatus:10
            })
        },
        create(record,editableFiexd){
            this.visible=true
            this.editableFiexd = editableFiexd
            this.$nextTick(()=>{
                this.$refs.modalForm.apply(record)
            })
        },
        edit (record,editableFiexd) {
            this.visible=true
            this.editableFiexd = editableFiexd
            this.$nextTick(()=>{
                this.$refs.modalForm.edit(record)
            })
        },
        review (record) {
            this.title = '查看'
            this.visible=true
            this.editable = false
            // this.dataId =record.id
            // // this.formData = record
            // this.disableSubmit = true

            this.$nextTick(()=>{
                this.$refs.modalForm.open(record)
            })
        },
        close () {
            this.$emit('close');
            this.title = ''
            this.editable = true
            this.formData = {}
            this.disableSubmit = false
            this.visible = false
            this.returnTimeEditable = false
            this.editableFiexd = {}
        },
        handleOk () {
            this.$refs.modalForm.submitForm().then(res=>{
                this.$emit('ok')
                this.visible = false
            })
        },
        handleCancel () {
            this.close()
        }
    }
}
</script>

<style>

</style>